/**
 * Created by vincent on 2016/12/23.
 */
function decimal(num, v) {
    var n = parseFloat(num);
    var vv = Math.pow(10, v);
    return Math.round(n * vv) / vv;
}

function initPagination(pagination, fun) {

}

function initPage(scope) {
    if (!Enums.loaded) {
        var value = window.sessionStorage.getItem('Enums');
        if (!!value && value != "undefined") {
            Enums = JSON.parse(value);
        }
    }
    if (scope) {
        scope.Enums = Enums;
        scope.EnumName = EnumName;
    }
    scope.updateSelection = updateSelection;

    var user = window.sessionStorage.getItem('user');
    if (!!user && user != "undefined") {
        user = JSON.parse(user);
    }
    scope.roleCode = user.roleCode;
    scope.showMoreSearch = false;
    scope.showMoreSearchFun = function (value) {
        scope.showMoreSearch = value;
    };
    $('.ngdialog-overlay')[0].style.zIndex = "-1";
    initPlugin();
}

function initPlugin() {
    if ($(".xn-search").length > 0) {
        /* XN-SEARCH */
        $(".xn-search").on("click", function () {
            $(this).find("input").focus();
        })
        /* END XN-SEARCH */
    }

}

var updateSelection = function ($event, field, fun) {
    if (field) {
        field = false;
    } else {
        field = true;
    }
    if (fun) {
        fun(field);
    }
}

function pageOnLoad(scope) {
    setTimeout(function () {
        templatePlugins.ready();
        templateActions.onload();
        !templateActions.load && templateActions.ready();
    }, 1000);

}

function pageResize() {
    setTimeout(function () {
       templateActions.onload();
    }, 1000);
}

function dialogOnLoad() {
    setTimeout(function () {
        templatePlugins.ready();
        !templateActions.load && templateActions.ready();
    }, 1000);
}

function isRealNum(val){
    // isNaN()函数 把空串 空格 以及NUll 按照0来处理 所以先去除
    if(val === "" || val ==null){
        return false;
    }
    if(!isNaN(val)){
        return true;
    }else{
        return false;
    }
}